]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
browser-plugin: The NPObject returned by NPP_GetValue should be retained
authorCarlos Garcia Campos <cgarcia@igalia.com>
Fri, 28 Oct 2016 13:33:11 +0000 (15:33 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Sat, 29 Oct 2016 07:08:07 +0000 (09:08 +0200)
The Mozilla documentation says: "And as always when working with
reference counted NPObjects, the caller is responsible for calling
NPN_ReleaseObject on the NPObject to drop the reference."

Browsers assume that the plugin does the right thing and always call
NPN_ReleaseObject. At some point the object is released and deallocated
and both the plugin and browser still have references to the object
thinking that it's still alive. That's why the crash is sometimes in the
plugin when it tries to use the np object, and sometimes in the browser.

https://bugzilla.gnome.org/post_bug.cgi

browser-plugin/browser-plugin.c

index 4555a9643ad80765b84c301de7a4f047a0da4d5a..35e15967ef6eea97221ac832c9e5e16deb466234 100644 (file)
@@ -1029,6 +1029,7 @@ NPP_GetValue(NPP          instance,
     if (!instance->pdata)
       return NPERR_INVALID_INSTANCE_ERROR;
 
+    funcs.retainobject (instance->pdata);
     *(NPObject**)value = instance->pdata;
     break;